home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / gnustuff / minix / libsrc~1.z / libsrc~1 / tmpnam.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-12-28  |  958 b   |  42 lines

  1. /* author:    Monty Walls
  2.  * written:    4/17/89
  3.  * Copyright:    Copyright (c) 1989 by Monty Walls.
  4.  *        Not derived from licensed software.
  5.  *
  6.  *        Permission to copy and/or distribute granted under the
  7.  *        following conditions:
  8.  *    
  9.  *        1). This notice must remain intact.
  10.  *        2). The author is not responsible for the consequences of use
  11.  *            this software, no matter how awful, even if they
  12.  *            arise from defects in it.
  13.  *        3). Altered version must not be represented as being the 
  14.  *            original software.
  15.  */
  16. #include <stdio.h>
  17. #include <string.h>
  18. #include <sys/types.h>
  19. #include <unistd.h>
  20.  
  21. #ifndef P_tmpdir
  22. #define P_tmpdir    "/tmp"
  23. #endif
  24.  
  25. #ifndef __STDC__
  26. extern char *mktemp(/* char * */);
  27. extern char *strcpy();
  28. extern char *strcat();
  29. #endif
  30.  
  31. char * tmpnam(buf)
  32. char *buf;
  33. {
  34.     static char our_buf[2*L_tmpnam];
  35.     register char *dest;
  36.  
  37.     dest = (buf == (char *)NULL ? our_buf: buf);
  38.     strcpy(dest, P_tmpdir);
  39.     strcat(dest, "/tmp.XXXXXX");
  40.     return(mktemp(dest));
  41. }
  42.